package com.meiyu.live.ui.search;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.meiyu.live.R;
import com.meiyu.live.util.DisplayUtils;

/**
 * Created by zbl on 2016/8/18.
 */
public class SearchTextView extends TextView {

    private String text;

    public SearchTextView(Context context) {
        super(context);
        init(context);
    }

    public SearchTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        setTextSize(15);
        int paddingleft = DisplayUtils.dpToPixel(context, 5);
        int paddingtop = paddingleft / 2;
        setPadding(paddingleft, paddingtop, paddingleft, paddingtop);
        setTextColor(0x40000000);
        setBackgroundResource(R.drawable.background_columnfollowview_n);
    }

    public void setData(String text) {
        this.text = text;
        update();
    }

    public String getData(){
        return text;
    }

    public void update(){
        if(text != null){
            setText(text);
        }
    }
}
